stylecontext: Add gtk_style_context_add_named()
authorBenjamin Otte <otte@redhat.com>
Sat, 5 Sep 2015 04:58:17 +0000 (06:58 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 22 Oct 2015 14:35:14 +0000 (16:35 +0200)
This is an intermediate step for cssnode introduction. It gives a name
for the node created by saving the style context.

gtk/gtkstylecontext.c
gtk/gtkstylecontextprivate.h

index 5d059a0956ad72e3a0aafec4f6e181213351c15d..f099b54aa8395afe4794485be3a77bce9bc3b180 100644 (file)
@@ -1179,6 +1179,29 @@ gtk_style_context_get_parent (GtkStyleContext *context)
   return context->priv->parent;
 }
 
+void
+gtk_style_context_save_named (GtkStyleContext *context,
+                              const char      *name)
+{
+  GtkStyleContextPrivate *priv;
+  GtkCssNode *cssnode;
+
+  priv = context->priv;
+
+  /* Make sure we have the style existing. It is the
+   * parent of the new saved node after all. */
+  if (!gtk_style_context_is_saved (context))
+    gtk_style_context_lookup_style (context);
+
+  cssnode = gtk_css_transient_node_new (priv->cssnode);
+  gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context));
+  if (name)
+    gtk_css_node_set_name (cssnode, g_intern_string (name));
+
+  priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
+  priv->cssnode = cssnode;
+}
+
 /**
  * gtk_style_context_save:
  * @context: a #GtkStyleContext
@@ -1196,24 +1219,9 @@ gtk_style_context_get_parent (GtkStyleContext *context)
 void
 gtk_style_context_save (GtkStyleContext *context)
 {
-  GtkStyleContextPrivate *priv;
-  GtkCssNode *cssnode;
-
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
 
-  priv = context->priv;
-
-  /* Make sure we have the style existing. It is the
-   * parent of the new saved node after all.
-   */
-  if (!gtk_style_context_is_saved (context))
-    gtk_style_context_lookup_style (context);
-
-  cssnode = gtk_css_transient_node_new (priv->cssnode);
-  gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context));
-
-  priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
-  priv->cssnode = cssnode;
+  gtk_style_context_save_named (context, NULL);
 }
 
 /**
index 4ba27fe3345c1c73fd22c7224a61ac4354032ce8..22ac942bc061b3d94b740a4b4995d80c52d6de42 100644 (file)
@@ -36,6 +36,9 @@ const char *    gtk_style_context_get_id                     (GtkStyleContext *c
 GtkStyleProviderPrivate *
                 gtk_style_context_get_style_provider         (GtkStyleContext *context);
 
+void            gtk_style_context_save_named                 (GtkStyleContext *context,
+                                                              const char      *name);
+
 const GtkBitmask *
                 _gtk_style_context_get_changes               (GtkStyleContext *context);